<?php
define('THUMB_DIR', dirname(__FILE__).DIRECTORY_SEPARATOR.'thumb'.DIRECTORY_SEPARATOR);
require_once '../../../lib/phpThumb/ThumbLib.inc.php';

$width = $_GET['width'];
$height = $_GET['height'];
$imageName = $_GET['imageName'];

$requested_file = THUMB_DIR.'thumb_'.$width.'_'.$height.'_'.$imageName;

if ( is_file($requested_file) ) {
	$thumb = PhpThumbFactory::create($requested_file);  
	$thumb->show();
} else {
	$enity_image = dirname(__FILE__).DIRECTORY_SEPARATOR.$imageName;
	$options = array('resizeUp' => true, 'jpegQuality' => 100);
	$thumb = PhpThumbFactory::create($enity_image,$options);
	$thumb->adaptiveResize($width,$height);
	$thumb->save($requested_file);
	$thumb->show(); 	
}
?>